#include <bits/stdc++.h>
using namespace std;
int r;

vector<int> div(vector<int> &a, int b) {
	vector<int> c;
	for (int i = a.size() - 1; i >= 0; --i) {
		r = r * 10 + a[i] ;
		c.push_back(r  / b);
		r %= b;
	}
	reverse(c.begin(), c.end());
	while (c.size() > 1 && c.back() == 0) {
		c.pop_back();
	}
	return c;
}

int main() {
	string A;
	int b;
	vector<int> a, c;
	cin >> A >> b;
	for (int i = A.size() - 1; i >= 0; --i) {
		a.push_back(A[i] - '0');
	}
	c = div(a, b);
	for (int i = c.size() - 1; i >= 0; --i) {
		cout << c[i];
	}
	cout << endl << r << endl;
	return 0;
}